package demo5;

import java.math.BigInteger;

public class code2 {
    public static void main(String[] args) {
        //创建两个BIgInteger对象
        BigInteger bd1 = BigInteger.valueOf(10);
        BigInteger bd2 = BigInteger.valueOf(2);

        //加法
        BigInteger bd3 = bd1.add(bd2);
        System.out.println(bd3);

        //除法
        BigInteger[] arr = bd1.divideAndRemainder(bd2);
        System.out.println(arr[0]);
        System.out.println(arr[1]);

        //比较是否相同
        boolean result = bd1.equals(bd2);
        System.out.println(result);

        //次幂
        BigInteger bd4 = bd1.pow(2);
        System.out.println(bd4);

        //max
        BigInteger bd5 = bd1.max(bd2);
        System.out.println(bd5);

        //转换为int类整数，超出范围数据有误,double等等的都可以但要注意不要超出定义范围，否则会报错
        //BigInteger bd6 = BigInteger.valueOf(21474836478);
        //int v = bd6.intValue();
        //System.out.println(v);
    }
}
